﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Configuration;
using System.Net;
using System.IO;
namespace ProcessesSMS
{
    /// <summary>
    /// Summary description for CKVN.
    /// </summary>
    public class TOURGREEN
    {

        private SMS_MO WMO;
        private SMS_MT WMT;
        //private SMS_LIST WML;
        ArrayList arr = new ArrayList();
        public TOURGREEN(SMS_MO MO)
        {
            WMO = MO;
        }

        public TOURGREEN()
        {
        }
        public void run()
        {
            WMT = new SMS_MT(WMO);
            //string tmpMsg = WMO.Message.Substring(WMO.CommandCode.Length).Trim().Replace("  ", " ").Replace("  ", " ");
            //tmpMsg = tmpMsg.Replace("  ", " ").Trim().ToUpper();
            //string[] msg = tmpMsg.Split(new char[] { ' ' });
            //if (strReturnMsg != "")
            //{
            //string[] strReturnMsg = GetReturnMsg(msg).Split('|');
            //for (int i = 0; i < strReturnMsg.Length; i++)
            //{
            WMT.AddMessage(WMO.UserID, GetReturnMsg(), SMS_ContentType.SMS_TEXT);
            WMT.MsgType = SMS_MsgType.SMS_TINHTIEN;
            //}
            WMT.Insert();
            //}
            return;
        }
        private string GetReturnMsg()
        {
            string msgBody = string.Empty;
            if (((WMO.ServiceID.Replace("04", "") == "6072") || (WMO.ServiceID.Replace("04", "") == "6172")) && WMO.UserID !="84902222776")
            {
                msgBody = "Xin loi ban.Dich vu cua chung toi chi ap dung cho dau so 6272";
            }
            else
            {                
                TourGreen.smswsdl ws = new ProcessesSMS.TourGreen.smswsdl();
                msgBody = ws.sms(WMO.ServiceID.Replace("04", ""), WMO.UserID, WMO.Message.Replace("  "," "));
            }
            return msgBody;
        }
    }
}
